<?php

namespace app\common\model\banxi\learn;

use app\common\model\banxi\say\SayTeachSentence;
use app\common\model\common\BaseModel;
use think\model\concern\SoftDelete;

/**
 * 全科习题答题记录
 */
class LearnSayAntiForgettingAnswer extends BaseModel
{
    use SoftDelete;

    protected $name = 'banxi_learn_say_anti_forgetting_answer';

    protected $autoWriteTimestamp = true;

    protected $deleteTime = 'del';

    protected $defaultSoftDelete = 0;

    protected $append = [
        'useTimeData',
        'sentenceWordColorList'
    ];

    protected $type = [
        'id' => 'string',
        'del' => 'string',
        'createTime' => 'timestamp:Y-m-d H:i:s',
        'updateTime' => 'timestamp:Y-m-d H:i:s',
    ];
    //-----------------------------------------------------------------------------------
    //｜                                   获取器                                       ｜
    //-----------------------------------------------------------------------------------

    public function getUseTimeDataAttr($value, $data)
    {
        $value = $value ?: ($data['useTime'] ?? '');
        return secondToTime($value);
    }

    public function getSentenceWordColorListAttr($value, $data)
    {
        $value = $value ?: ($data['sentenceWordColor'] ?? '');
        return json_decode($value, true) ?? [];
    }

    //-----------------------------------------------------------------------------------
    //｜                                   处理方法                                       ｜
    //-----------------------------------------------------------------------------------

    //-----------------------------------------------------------------------------------
    //｜                                   模型关联                                       ｜
    //-----------------------------------------------------------------------------------

}